package test;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
	    Map<String, Integer> map = new TreeMap<String, Integer>();
	    while(in.hasNext()){
	    		String str = in.next();
				if(map.containsKey(str)){
					Integer num = map.get(str);
					map.put(str, num+1);
				}
				else {
					map.put(str, 1);
					map.remove("!!!!!");
				}
	    	    if(str.equals("!!!!!"))  break;
	    }
	    in.close();
	    System.out.println(map.size());
	    List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(map.entrySet());      
	    Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
            
	    	public int compare(Map.Entry<String, Integer> left, Map.Entry<String, Integer> right) {
                return (right.getValue()-left.getValue());
            }
        }); 
        for (int i = 0; i < 10; i++) 
            System.out.println(list.toArray()[i]);       
    }
}    





